home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume2 / kernel / whatcpu1.1 < prev    next >
Internet Message Format  |  1988-12-28  |  5KB

  1. Path: xanth!nic.MR.NET!hal!cwjcc!mailrus!cornell!rochester!bbn!ulowell!page
  2. From: page@swan.ulowell.edu (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v02i104:  whatcpu - check and print cpu type v1.1
  5. Message-ID: <10941@swan.ulowell.edu>
  6. Date: 28 Dec 88 19:23:54 GMT
  7. Organization: University of Lowell, Computer Science Dept.
  8. Lines: 168
  9. Approved: page@swan.ulowell.edu
  10.  
  11. Submitted-by: erd@cis.ohio-state.edu (Ethan R. Dicks)
  12. Posting-number: Volume 2, Issue 104
  13. Archive-name: kernel/whatcpu11.1
  14.  
  15. [uuencoded executable included.  ..Bob]
  16.  
  17. #    This is a shell archive.
  18. #    Remove everything above and including the cut line.
  19. #    Then run the rest of the file through sh.
  20. #----cut here-----cut here-----cut here-----cut here----#
  21. #!/bin/sh
  22. # shar:    Shell Archiver
  23. #    Run the following text with /bin/sh to create:
  24. #    WhatCPU.asm
  25. #    WhatCPU.uu
  26. # This archive created: Wed Dec 28 14:18:14 1988
  27. cat << \SHAR_EOF > WhatCPU.asm
  28. ; WhatCPU.asm
  29. ;
  30. ; Actually a hand conversion of WhatCPU.c by Dave Haynie
  31. ;    done by Ethan Dicks 14-mar-88
  32. ;    beautification done by Ethan Dicks 14-Dec-88
  33. ;
  34. ; I did this as my first project in assembler.  Documentation is very
  35. ; scanty regarding the use of structures in assembler.  I got the magic
  36. ; offset into the ExecBase structure for the AttnFlags word by compiling
  37. ; Dave Haynie's program with Lattice, on a friend's machine, then
  38. ; running omd on the .o file.
  39. ;
  40. ; V 1.1
  41. ;  Since I got a copy of the C-A v1.0 Macro Assembler, and the assembler
  42. ;  includes with Lattice V4.01, I have been able to convert this program
  43. ;  over to the niceties of INCLUDE files.  I also too the opportunity to
  44. ;  streamline the code to the tune of about 40 bytes, making this one of
  45. ;  the smallest useful utilities.
  46. ;
  47. ;
  48. ; This program was most recently compiled on:
  49. ;
  50. ; assem
  51. ;    MC68000 Macro Assembler  Version 10.178
  52. ;    Copyright (C) 1985 by Tenchstar Ltd., T/A Metacomco.
  53. ;    All rights reserved.
  54. ;
  55. ; Blink
  56. ;    Blink - Version 5.0
  57. ;    Copyright (c) 1988 Lattice, Inc.  All Rights Reserved.
  58. ;
  59. ;
  60. ; To recompile:
  61. ;    assem WhatCPU.asm -i your_include_directory -o WhatCPU.o
  62. ;    blink WhatCPU.o
  63. ;
  64. ; This code is freely redistributable, although not pretty.
  65. ;
  66.     section    code
  67.  
  68.  
  69.         include    "exec/execbase.i"
  70.         include "libraries/dos.i"
  71.         include "libraries/dos_lib.i"
  72.         include "exec/funcdef.i"
  73.         include "exec/exec_lib.i"
  74.  
  75. AbsExecBase    equ    4
  76.  
  77. start:        movea.l    AbsExecBase,a6        ;save pointer to Execbase in a6
  78.         lea    dos_name(pc),a1        ;point to library name
  79.         moveq.l    #0,d0            ;pick any version
  80.         jsr    _LVOOpenLibrary(a6)    ;open dos.library
  81.         movea.l    d0,a5            ;save DosBase in A5
  82.         jsr    _LVOOutput(a5)      ;get OutputHandle into D0
  83.         move.l    d0,d5            ;save OutputHandle in D5
  84. ;
  85. ; print title message
  86. ;
  87.         move.l    #header,d2        ;print intro message
  88.         move.l    #22,d3            ; 22 chars long
  89.         bsr.s    print           ;output string
  90. ;
  91. ; check processor type bits
  92. ;
  93.         btst.b    #AFB_68020,AttnFlags+1(a6) ;check 68020 bit
  94.         beq.s    not68020        ;nope... not set
  95.         move.l    #mc68020,d2        ;point to "68020"
  96.         moveq.l    #6,d3            ; 6 chars long
  97.         bra.s    break            ;print processor type and
  98.                         ;  check co-processor bit
  99. ;
  100. not68020:    btst.b    #AFB_68010,AttnFlags+1(a6) ;check 68010 bit
  101.         beq.s    not68010        ;nope... not set
  102.         move.l    #mc68010,d2        ;point to "68010"
  103.         moveq.l    #6,d3            ; 6 chars long
  104.         bra.s    break            ;print processor type and
  105.                         ; check co-processor bit
  106. ;
  107. not68010:    move.l    #mc68000,d2        ;must be 68000; print it
  108.         moveq.l    #6,d3            ; 6 chars long
  109.                         ;print processor type and
  110.                         ; check co-processor bit
  111.                         ;
  112.                         ; *** WARNING ***
  113.                         ;*  Fall through *
  114.                         ; ***************
  115. ;
  116. break:        bsr.s    print            ;output processor string
  117.  
  118.         btst.b    #AFB_68881,AttnFlags+1(a6) ;check 68881 bit
  119.         beq.s    not68881        ;nope... not set
  120.         move.l    #mc68881,d2        ;print "68881"
  121.         moveq.l    #6,d3            ; 6 chars long
  122.         bsr.s    print
  123. not68881:
  124. ;
  125. ; print <CR> at end of line
  126. ;
  127.         move.l    #cr,d2            ;finish off with <crlf>
  128.         moveq.l    #2,d3            ; 2 chars long
  129.         bsr.s    print   
  130. ;
  131. ; clean up and exit
  132. ;
  133.         movea.l    a5,a1            ;get DosBase
  134.         jsr    _LVOCloseLibrary(a6)    ;close dos.library
  135.         moveq.l    #0,d0            ;set return code
  136.         rts                ;go home
  137. ;
  138. ; subroutines
  139. ;
  140. print:        move.l  d5,d1            ;set output handle
  141.         jsr     _LVOWrite(a5)        ;write string to console
  142.         rts                ;go back
  143. ;
  144. ; data section
  145. ;
  146.  
  147. ;
  148. ; byte aligned data
  149. ;
  150. dos_name:    DOSNAME
  151. header:        dc.b    'System Configuration: '
  152. mc68020:    dc.b    '68020 '
  153. mc68010:    dc.b    '68010 '
  154. mc68000:    dc.b    '68000 '
  155. mc68881:    dc.b    '68881 '
  156. cr:        dc.b    13,10
  157.  
  158.         end
  159.  
  160. SHAR_EOF
  161. cat << \SHAR_EOF > WhatCPU.uu
  162.  
  163. begin 777 WhatCPU
  164. M```#\P`````````!```````````````O```#Z0```"\L>``$0_H`>G``3J[])
  165. MV"I`3JW_Q"H`)#P```",)CP````6850(+@`!`2EG"B0\````HG8&8!H(+@``#
  166. M`2EG"B0\````J'8&8`@D/````*YV!F$F""X`!`$I9PHD/````+1V!F$4)#P`2
  167. M``"Z=@)A"B)-3J[^8G``3G4B!4ZM_]!.=61O<RYL:6)R87)Y`%-Y<W1E;2!#@
  168. M;VYF:6=U<F%T:6]N.B`V.#`R,"`V.#`Q,"`V.#`P,"`V.#@X,2`-"@```^P`!
  169. G```&`````````&8```!<````2@```$`````N````&`````````/R-
  170. ``
  171. end
  172. size 264
  173. SHAR_EOF
  174. #    End of shell archive
  175. exit 0
  176. -- 
  177. Bob Page, U of Lowell CS Dept.  page@swan.ulowell.edu  ulowell!page
  178. Have five nice days.
  179.